<?php
namespace ClubAdmin\Controller;
use Think\Controller;
class VideoController extends BaseController {

public function video(){

 $this->display();
      
 }

public function videoadd($club_id,$video_mv,$video_name,$video_hit,$video_publisher,$video_flag){
       
        if($_FILES['file']['error']==0 ){
            $info=$this->upload();
            $name=$info["file"]["savename"];
        }
        else{
            $name="default.jpg";
        }

        $videomodel = M("video");
        $videomodel->club_id=$club_id;
        $videomodel->video_mv=$video_mv;
        $videomodel->video_name=$video_name;
        $videomodel->video_date=date('Y-m-d H:i:s');
        $videomodel->video_hit=$video_hit;
        $videomodel->video_publisher=$video_publisher;
        $videomodel->video_flag=$video_flag;
        $videomodel->video_pic=$name;
        $res = $videomodel->add();
        if (false !== $res){
            $this->success('添加成功');
        }else{
            $this->error('信息填写有误');
        }
      }
public function upload(){

        $upload = new \Think\Upload();
        $upload->maxSize   =     3145728 ;
        $upload->exts      =     array('jpg', 'gif', 'png', 'jpeg');
        $upload->rootPath  = './Public/pic/'; 
        $upload->autoSub = false;
        $info   =   $upload->upload();  
        if(!$info) {
            $this->error($upload->getError());
        }
        else{
            return $info;
        }                    
        }

 }